import axios from '@/request/index.js'
//基本请求方法
const Get = ({
    url = '',
    params = {},
    headers = {}
}) => {
    return axios({
        method: 'get',
        url,
        params,
        headers
    })
}

const Post = ({
    url = '',
    params = {},
    headers = {}
}) => {
    return axios({
        method: 'post',
        url,
        data: params,
        headers
    })
}

const Delete = ({
    url = '',
    params = {},
    headers = {}
}) => {
    return axios({
        method: 'delete',
        url,
        params,
        headers
    })
}

const Put = ({
    url = '',
    params = {},
    headers = {}
}) => {
    return axios({
        method: 'put',
        url,
        data: params,
        headers
    })
}

/*
 * 所有请求
 */

//合集列表
const list = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
                url: '/api/collection/list',
                params
            })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}

//我的合集列表
const mylist = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
                url: '/api/collection/my_list',
                params
            })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//合集详情页
const detailAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
                url: '/api/collection/detail',
                params
            })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//藏品列表
const itemsAPIS = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
                url: '/api/item/items',
                params
            })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
// 发送验证码
const authcode = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/auth/sms/code',
            params,
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//邮箱登录
const login = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/auth/email/login',
            params,
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//邮箱登录
const register = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/auth/email/register',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//获取用户登录信息  
const detail = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/member/me/detail',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//更新自己的用户信息
const userdetail = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/member/me/detail',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//获取自己的用户信息

//文件上传
const upload = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/tool/upload',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//创建合集
const create = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/collection/create',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//修改合集
const editAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/collection/edit',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//我的收藏
const getlist = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/item/list',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//我的喜欢
const likes = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/member/likes',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//我的关注
const following = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/member/following',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//我的粉丝
const followers = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/member/followers',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//获取用户卡片信息
const card = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/member/card',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//获取用户收藏列表信息
const user_items = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
                url: '/api/member/user_items',
                params
            })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//获取用户创建列表
const user_create = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
                url: '/api/member/user_create',
                params
            })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//获取用户关注列表
const user_follows = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
                url: '/api/member/user_follows',
                params
            })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//出价藏品
const exchange = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/member/bid/offer',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//收到报价
const listsapi = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/member/bid/received',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//我的藏品
const itemsAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/item/myList',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//点赞取消点赞
const like = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/member/like',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//积分兑换
const initapi = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/member/point/init',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//关注取消关注
const followAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/member/follow',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//创建藏品
const itemCreate = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/item/create',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//创建藏品后的回调
const itemCreateAfter = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/item/minted',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//上架藏品后的回调
const putedAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/item/puted',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}

    
//藏品详情页
const detailAPIs = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/item/detail',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//消息通知列表
const notify_list = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/member/notify/list',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//设置用通知类型
const notifyAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/member/notify/setting',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//获取通知类型
const getNotifyAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/member/notify/setting',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//获取首页热门
const listAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/index/list',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//邮箱忘记密码
const forgetAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/auth/email/password/forget',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//钱包登录
const loginAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/auth/wallet/login',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//获取钱包签名
const getWalletSign = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/auth/wallet/signature',
            params
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}
//藏品详情
const itemDetail = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/item/detail',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//钱包登录
const walletLogin = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/auth/wallet/login',
            params
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
                reject(err)
        })
    })
}
//排行榜
const rankAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/data/rank',
            params
        })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//市场交易
const saleAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
                url: '/api/data/sale',
                params
            })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//中间商手续费
const feeAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
                url: '/api/siteSetting/fee_recipient',
                params
            })
            .then((res) => {
                resolve(res)
            })
            .catch((err) => {
                reject(err)
            })
    })
}
//售卖
const exchangecreate = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/item/exchange_create',
            params
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}
//钱包绑定
const bindAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/member/wallet/bind',
            params
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}
//i18n配置
const i18nAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/i18n',
            params
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}
//立即购买
const buyAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/item/buy',
            params
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}
//立即购买成功后的回调
const buyedAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/item/buyed',
            params
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}
//英式出价
const bidAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/item/bid',
            params
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}
//英式出价成功后的回调
const bidedAPI = (params = {}) => {
    return new Promise((resolve, reject) => {
        Post({
            url: '/api/item/bided',
            params
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}
//汇率
const rate_config = (params = {}) => {
    return new Promise((resolve, reject) => {
        Get({
            url: '/api/siteSetting/rate_config',
            params
        }).then((res) => {
            resolve(res)
        }).catch((err) => {
            reject(err)
        })
    })
}

export default {
    authcode,
    Get,
    Post,
    Delete,
    Put,
    list,
    login,
    register,
    detail,
    userdetail,
    upload,
    getlist,
    likes,
    following,
    followers,
    card,
    create,
    exchange,
    like,
    initapi,
    listsapi,
    followAPI,
    itemsAPI,
    notify_list,
    notifyAPI,
    getNotifyAPI,
    listAPI,
    itemCreate,
    forgetAPI,
    loginAPI,
    itemDetail,
    mylist,
    getWalletSign,
    detailAPI,
    itemsAPIS,
    walletLogin,
    detailAPIs,
    rankAPI,
    saleAPI,
    user_items,
    user_create,
    user_follows,
    itemCreateAfter,
    exchangecreate,
    feeAPI,
    putedAPI,
    bindAPI,
    i18nAPI,
    buyAPI,
    buyedAPI,
    bidedAPI,
    bidAPI,
    rate_config,
    editAPI,
}
